package day0610

/**
  * @program: hadoop
  * @description: 样本类
  * @author: Qiang.Ye
  * @date: 2019-06-11 07:57
  *
  *  作用：
  *  1.支持匹配模式，相当于java中的instanceof
  *  2.定义Spark SQL 的Schema：定义Spark SQL 的表结构
  *
  *
  **/

class Vehiche

case  class  Car1 (name : String ) extends  Vehiche
case  class  Bike1 (name : String ) extends  Vehiche

object Demo02 {

  /**
    *
  scala> class Fruit
  defined class Fruit

  scala> class Apple(name:String) extends Fruit
  defined class Apple

  scala> class Banana(name: String) extends Fruit
  defined class Banana
    */
  def main(args: Array[String]): Unit = {
    var aCar :Vehiche = new Car1("Car")
    aCar match {
      case  Car1(name) => println("汽车："+name)
      case  Bike1(name) => println("自行车："+name)
      case _ => println("其他")
    }
  }

}
